const Controllers = require('../controllers/Controller.js').controller;
const app = getApp();
Page({
  data: {
    globalStype:'',
    globalStype:'',
  	goodsCommentPagedata:[],
    pageNumber:1,
    pageSize:10,
    isEnd:false,
    isloading:true,
    imgList2:[]
  },
  onLoad(option) {
    this.setData({globalStype:app.globalData.globalStype})
  	if(option.id){
      this.setData({
        goodsId:option.id
      })
      this.goodsCommentPage()
    }
    if(app.globalData.shopId){
      this.setData({
        shopId:app.globalData.shopId
      })
    }
  },
  goodsCommentPage(){
    Controllers.goodsCommentPage({
      pageSize:this.data.pageSize,
      pageNumber:this.data.pageNumber,
      goodsId:this.data.goodsId
    }).then(res => {
      if(res.data.list.length>0){
        this.setData({
          goodsCommentPagedata:this.data.goodsCommentPagedata.concat(res.data.list),

        })
        
      }
      if(res.data.lastPage){
          this.setData({
            isEnd:true
          })
        }
      this.setData({
      	isloading:false
      })
    });
  },
  onReachBottom() {
    if (this.data.isEnd) {
      return;
    } else {
      this.setData({
          pageNumber: this.data.pageNumber + 1,
      });
      this.goodsCommentPage()
    }
  },
  preview(event) {
    let currentUrl = event.currentTarget.dataset.src
    let lists=[]
    for(let item of event.currentTarget.dataset.lists){
      lists.push(item.image)
    }
    wx.previewImage({
      current: currentUrl, // 当前显示图片的http链接
      urls: lists // 需要预览的图片http链接列表
    })
  },
})